package com.kk.xhr.model.dao;

import static com.kk.xhr.model.dao.EmployeeDynamicSqlSupport.*;
import static org.mybatis.dynamic.sql.SqlBuilder.*;

import com.kk.xhr.model.entity.Employee;
import java.util.List;
import java.util.Optional;
import javax.annotation.Generated;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.mybatis.dynamic.sql.BasicColumn;
import org.mybatis.dynamic.sql.delete.DeleteDSLCompleter;
import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider;
import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider;
import org.mybatis.dynamic.sql.select.CountDSLCompleter;
import org.mybatis.dynamic.sql.select.SelectDSLCompleter;
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
import org.mybatis.dynamic.sql.update.UpdateDSL;
import org.mybatis.dynamic.sql.update.UpdateDSLCompleter;
import org.mybatis.dynamic.sql.update.UpdateModel;
import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider;
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;
import org.mybatis.dynamic.sql.util.mybatis3.MyBatis3Utils;

@Mapper
public interface EmployeeMapper {
    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: employee")
    BasicColumn[] selectList = BasicColumn.columnList(id, userId, avatarUrl, name, gender, birthday, idcard, wedlock, nationId, nativeplace, politicId, email, phone, address, form, degree, specialty, school, begin, end, status, created, updated);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: employee")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    long count(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: employee")
    @DeleteProvider(type=SqlProviderAdapter.class, method="delete")
    int delete(DeleteStatementProvider deleteStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: employee")
    @InsertProvider(type=SqlProviderAdapter.class, method="insert")
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="record.id", before=false, resultType=Long.class)
    int insert(InsertStatementProvider<Employee> insertStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: employee")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @ResultMap("EmployeeResult")
    Optional<Employee> selectOne(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: employee")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @Results(id="EmployeeResult", value = {
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="user_id", property="userId", jdbcType=JdbcType.BIGINT),
        @Result(column="avatar_url", property="avatarUrl", jdbcType=JdbcType.VARCHAR),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="gender", property="gender", jdbcType=JdbcType.TINYINT),
        @Result(column="birthday", property="birthday", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="idCard", property="idcard", jdbcType=JdbcType.CHAR),
        @Result(column="wedlock", property="wedlock", jdbcType=JdbcType.TINYINT),
        @Result(column="nation_id", property="nationId", jdbcType=JdbcType.BIGINT),
        @Result(column="nativeplace", property="nativeplace", jdbcType=JdbcType.VARCHAR),
        @Result(column="politic_id", property="politicId", jdbcType=JdbcType.BIGINT),
        @Result(column="email", property="email", jdbcType=JdbcType.VARCHAR),
        @Result(column="phone", property="phone", jdbcType=JdbcType.VARCHAR),
        @Result(column="address", property="address", jdbcType=JdbcType.VARCHAR),
        @Result(column="form", property="form", jdbcType=JdbcType.TINYINT),
        @Result(column="degree", property="degree", jdbcType=JdbcType.TINYINT),
        @Result(column="specialty", property="specialty", jdbcType=JdbcType.VARCHAR),
        @Result(column="school", property="school", jdbcType=JdbcType.VARCHAR),
        @Result(column="begin", property="begin", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="end", property="end", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="status", property="status", jdbcType=JdbcType.TINYINT),
        @Result(column="created", property="created", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="updated", property="updated", jdbcType=JdbcType.TIMESTAMP)
    })
    List<Employee> selectMany(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: employee")
    @UpdateProvider(type=SqlProviderAdapter.class, method="update")
    int update(UpdateStatementProvider updateStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: employee")
    default long count(CountDSLCompleter completer) {
        return MyBatis3Utils.countFrom(this::count, employee, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: employee")
    default int delete(DeleteDSLCompleter completer) {
        return MyBatis3Utils.deleteFrom(this::delete, employee, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: employee")
    default int deleteByPrimaryKey(Long id_) {
        return delete(c -> 
            c.where(id, isEqualTo(id_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: employee")
    default int insert(Employee record) {
        return MyBatis3Utils.insert(this::insert, record, employee, c ->
            c.map(userId).toProperty("userId")
            .map(avatarUrl).toProperty("avatarUrl")
            .map(name).toProperty("name")
            .map(gender).toProperty("gender")
            .map(birthday).toProperty("birthday")
            .map(idcard).toProperty("idcard")
            .map(wedlock).toProperty("wedlock")
            .map(nationId).toProperty("nationId")
            .map(nativeplace).toProperty("nativeplace")
            .map(politicId).toProperty("politicId")
            .map(email).toProperty("email")
            .map(phone).toProperty("phone")
            .map(address).toProperty("address")
            .map(form).toProperty("form")
            .map(degree).toProperty("degree")
            .map(specialty).toProperty("specialty")
            .map(school).toProperty("school")
            .map(begin).toProperty("begin")
            .map(end).toProperty("end")
            .map(status).toProperty("status")
            .map(created).toProperty("created")
            .map(updated).toProperty("updated")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: employee")
    default int insertSelective(Employee record) {
        return MyBatis3Utils.insert(this::insert, record, employee, c ->
            c.map(userId).toPropertyWhenPresent("userId", record::getUserId)
            .map(avatarUrl).toPropertyWhenPresent("avatarUrl", record::getAvatarUrl)
            .map(name).toPropertyWhenPresent("name", record::getName)
            .map(gender).toPropertyWhenPresent("gender", record::getGender)
            .map(birthday).toPropertyWhenPresent("birthday", record::getBirthday)
            .map(idcard).toPropertyWhenPresent("idcard", record::getIdcard)
            .map(wedlock).toPropertyWhenPresent("wedlock", record::getWedlock)
            .map(nationId).toPropertyWhenPresent("nationId", record::getNationId)
            .map(nativeplace).toPropertyWhenPresent("nativeplace", record::getNativeplace)
            .map(politicId).toPropertyWhenPresent("politicId", record::getPoliticId)
            .map(email).toPropertyWhenPresent("email", record::getEmail)
            .map(phone).toPropertyWhenPresent("phone", record::getPhone)
            .map(address).toPropertyWhenPresent("address", record::getAddress)
            .map(form).toPropertyWhenPresent("form", record::getForm)
            .map(degree).toPropertyWhenPresent("degree", record::getDegree)
            .map(specialty).toPropertyWhenPresent("specialty", record::getSpecialty)
            .map(school).toPropertyWhenPresent("school", record::getSchool)
            .map(begin).toPropertyWhenPresent("begin", record::getBegin)
            .map(end).toPropertyWhenPresent("end", record::getEnd)
            .map(status).toPropertyWhenPresent("status", record::getStatus)
            .map(created).toPropertyWhenPresent("created", record::getCreated)
            .map(updated).toPropertyWhenPresent("updated", record::getUpdated)
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: employee")
    default Optional<Employee> selectOne(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectOne(this::selectOne, selectList, employee, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: employee")
    default List<Employee> select(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectList(this::selectMany, selectList, employee, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: employee")
    default List<Employee> selectDistinct(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectDistinct(this::selectMany, selectList, employee, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: employee")
    default Optional<Employee> selectByPrimaryKey(Long id_) {
        return selectOne(c ->
            c.where(id, isEqualTo(id_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: employee")
    default int update(UpdateDSLCompleter completer) {
        return MyBatis3Utils.update(this::update, employee, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: employee")
    static UpdateDSL<UpdateModel> updateAllColumns(Employee record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(userId).equalTo(record::getUserId)
                .set(avatarUrl).equalTo(record::getAvatarUrl)
                .set(name).equalTo(record::getName)
                .set(gender).equalTo(record::getGender)
                .set(birthday).equalTo(record::getBirthday)
                .set(idcard).equalTo(record::getIdcard)
                .set(wedlock).equalTo(record::getWedlock)
                .set(nationId).equalTo(record::getNationId)
                .set(nativeplace).equalTo(record::getNativeplace)
                .set(politicId).equalTo(record::getPoliticId)
                .set(email).equalTo(record::getEmail)
                .set(phone).equalTo(record::getPhone)
                .set(address).equalTo(record::getAddress)
                .set(form).equalTo(record::getForm)
                .set(degree).equalTo(record::getDegree)
                .set(specialty).equalTo(record::getSpecialty)
                .set(school).equalTo(record::getSchool)
                .set(begin).equalTo(record::getBegin)
                .set(end).equalTo(record::getEnd)
                .set(status).equalTo(record::getStatus)
                .set(created).equalTo(record::getCreated)
                .set(updated).equalTo(record::getUpdated);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: employee")
    static UpdateDSL<UpdateModel> updateSelectiveColumns(Employee record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(userId).equalToWhenPresent(record::getUserId)
                .set(avatarUrl).equalToWhenPresent(record::getAvatarUrl)
                .set(name).equalToWhenPresent(record::getName)
                .set(gender).equalToWhenPresent(record::getGender)
                .set(birthday).equalToWhenPresent(record::getBirthday)
                .set(idcard).equalToWhenPresent(record::getIdcard)
                .set(wedlock).equalToWhenPresent(record::getWedlock)
                .set(nationId).equalToWhenPresent(record::getNationId)
                .set(nativeplace).equalToWhenPresent(record::getNativeplace)
                .set(politicId).equalToWhenPresent(record::getPoliticId)
                .set(email).equalToWhenPresent(record::getEmail)
                .set(phone).equalToWhenPresent(record::getPhone)
                .set(address).equalToWhenPresent(record::getAddress)
                .set(form).equalToWhenPresent(record::getForm)
                .set(degree).equalToWhenPresent(record::getDegree)
                .set(specialty).equalToWhenPresent(record::getSpecialty)
                .set(school).equalToWhenPresent(record::getSchool)
                .set(begin).equalToWhenPresent(record::getBegin)
                .set(end).equalToWhenPresent(record::getEnd)
                .set(status).equalToWhenPresent(record::getStatus)
                .set(created).equalToWhenPresent(record::getCreated)
                .set(updated).equalToWhenPresent(record::getUpdated);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: employee")
    default int updateByPrimaryKey(Employee record) {
        return update(c ->
            c.set(userId).equalTo(record::getUserId)
            .set(avatarUrl).equalTo(record::getAvatarUrl)
            .set(name).equalTo(record::getName)
            .set(gender).equalTo(record::getGender)
            .set(birthday).equalTo(record::getBirthday)
            .set(idcard).equalTo(record::getIdcard)
            .set(wedlock).equalTo(record::getWedlock)
            .set(nationId).equalTo(record::getNationId)
            .set(nativeplace).equalTo(record::getNativeplace)
            .set(politicId).equalTo(record::getPoliticId)
            .set(email).equalTo(record::getEmail)
            .set(phone).equalTo(record::getPhone)
            .set(address).equalTo(record::getAddress)
            .set(form).equalTo(record::getForm)
            .set(degree).equalTo(record::getDegree)
            .set(specialty).equalTo(record::getSpecialty)
            .set(school).equalTo(record::getSchool)
            .set(begin).equalTo(record::getBegin)
            .set(end).equalTo(record::getEnd)
            .set(status).equalTo(record::getStatus)
            .set(created).equalTo(record::getCreated)
            .set(updated).equalTo(record::getUpdated)
            .where(id, isEqualTo(record::getId))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: employee")
    default int updateByPrimaryKeySelective(Employee record) {
        return update(c ->
            c.set(userId).equalToWhenPresent(record::getUserId)
            .set(avatarUrl).equalToWhenPresent(record::getAvatarUrl)
            .set(name).equalToWhenPresent(record::getName)
            .set(gender).equalToWhenPresent(record::getGender)
            .set(birthday).equalToWhenPresent(record::getBirthday)
            .set(idcard).equalToWhenPresent(record::getIdcard)
            .set(wedlock).equalToWhenPresent(record::getWedlock)
            .set(nationId).equalToWhenPresent(record::getNationId)
            .set(nativeplace).equalToWhenPresent(record::getNativeplace)
            .set(politicId).equalToWhenPresent(record::getPoliticId)
            .set(email).equalToWhenPresent(record::getEmail)
            .set(phone).equalToWhenPresent(record::getPhone)
            .set(address).equalToWhenPresent(record::getAddress)
            .set(form).equalToWhenPresent(record::getForm)
            .set(degree).equalToWhenPresent(record::getDegree)
            .set(specialty).equalToWhenPresent(record::getSpecialty)
            .set(school).equalToWhenPresent(record::getSchool)
            .set(begin).equalToWhenPresent(record::getBegin)
            .set(end).equalToWhenPresent(record::getEnd)
            .set(status).equalToWhenPresent(record::getStatus)
            .set(created).equalToWhenPresent(record::getCreated)
            .set(updated).equalToWhenPresent(record::getUpdated)
            .where(id, isEqualTo(record::getId))
        );
    }
}